-
Notifications
You must be signed in to change notification settings - Fork 466
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[fix] Allow to convert 3/5/7/9/11/13/15 bpp JP2 files to TIF #729
Conversation
Cool : I saw this problem with sentinel images. 15 bpp was failing. |
It might be wise to add an odd bit depth JP2 image to the test suite. |
@julienmalik I agree with Aaron. Could you provide such odd bit depth JP2 image so that we can add it to the test suite and reproduce the bug before fixing it ? Best way to do so is to create a PR in openjpeg-data with the new file and then add the test in https://github.com/uclouvain/openjpeg/blob/master/tests/nonregression/test_suite.ctest.in |
Agreed |
After further testing, seems like 12bpp TIFF is not supported by all implementation, so it could help to have a command line option to force the bitdepth of the output. I'll try to come up with something. |
@julienmalik, the command line option to force output bit depth already exists.
|
many thanks @mayeut ! much more than actually expected ! |
This issue comes from the decompression of Sentinel-2 Earth Observation satellite products, which are currently delivered as 15-bpp JP2 files.
OpenJPEG 2.0.1 and 2.1 are affected by a serious bug when using opj_decompress to convert the JP2 files to TIF format : the actual pixels values are twice the expected values.
Current trunk simply refuses to convert the data to TIF and errors out with the message :
This commit simply considers the unsupported 3/5/7/9/11/13/15 bit-precision as if they were 4/6/8/10/12/14/16 bpp data, to at least allow TIF conversion. The bug affecting 2.0.1 and 2.1 cannot be reproduced then, and pixel values in TIF are as expected.
Please note that Kakadu does output a 15 bpp TIF :
while with this fix, OpenJPEG outputs a 16bpp TIF :
I do have some issues with the 15bpp TIFF files in other software (namely the Java JAI TIF reader), so for my use case it is better to keep only 1, 2, 4, 6, 8, 10, 12, 14 and 16 bits TIF.